package com.baizhi.user.controller;

import com.baizhi.model.entity.User;
import com.baizhi.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author gange
 * @since 2023-07-18
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;
    @GetMapping("/users")
    public Map<String,Object> selectUsers(
            int page,
            int per_page,
            Integer id,
            String name,
            String phone
    ){
        return userService.selectUser(page,per_page,id,name,phone);
    }


    @GetMapping("/selectByName/{name}")
    public List<User> selectByName(@PathVariable("name") String name){
        return userService.query().like("name",name).list();
    }

    @GetMapping("/selectById/{id}")
    public User selectById(@PathVariable("id") Integer id){
        return userService.getById(id);
    }
}

